package game.view.panel.other
{
	import com.base.type.LayerEnum;
	import com.greensock.TweenMax;
	
	import flash.display.DisplayObjectContainer;
	import flash.geom.Point;
	
	import game.view.base.component.LabelNoticeViewUI;
	
	import morn.App;
	
	public class LabelNoticeView extends LabelNoticeViewUI
	{
		
		private static var _instance:LabelNoticeView;
		public var isToPiao:Boolean=true;
		public static function get instance():LabelNoticeView
		{
			/*if (_instance==null)*/
			//_instance = new LabelNoticeView();
			//return _instance;
			return new LabelNoticeView();
		}
		
		public function LabelNoticeView()
		{
			super();
		}
		/**
		 * FF6633
		 * @param notice
		 * @param point
		 * @param distance
		 * @param isBg:是否显示背景
		 */		
		public function showNotice(notice:String,point:Point=null,distance:Number=-400,duration:Number=6,container:DisplayObjectContainer=null,isBg:Boolean=true):void
		{
		
			bg.visible=isBg;
			//bg.x=500;
			label.text = notice;
			if (point) 
			{
				this.x = point.x;
				this.y = point.y;
			}
			else
			{
				this.x = 0;
				//this.y =90;
				this.y = App.stage.stageHeight*0.5;
			}
			if (container==null) 
			{
				container = ZooMain.view.getLayerByName(LayerEnum.LAYER_NOTICE);
			}
			/*for(var i:int=0;i<container.numChildren;i++){
				container.getChildAt(i).y-=46;
			}*/
			//trace(container.numChildren);
			showOrHide(true,container,distance,duration);
		}
		
		private function showOrHide(value:Boolean,container:DisplayObjectContainer=null,distance:Number=-200,duration:Number=2):void
		{
			if (value&&container) 
			{
				container.addChild(this);
				if(!isToPiao)return;
				tweenMove(distance,duration);
			}
			else if(this.parent)
			{
				TweenMax.killTweensOf(this);
				this.parent.removeChild(this);
			}
		}
		
		private function tweenMove(distance:Number,duration:Number):void
		{
			var temp:String = distance.toString();
			TweenMax.to(this,duration,{y:temp,autoAlpha:1,onComplete:tweenComplete,onCompleteParams:[]});
			//TweenMax.to(this,duration,{autoAlpha:1,onComplete:tweenComplete,onCompleteParams:[]});
		}
		
		private function tweenComplete():void
		{
			
			//trace("LabelNoticeView tweenComplete");
			showOrHide(false);
		}
	}
}